Skip to content

test(shader-transitions): add midpoint (p=0.5) regression invariants for all shaders#378

Merged
vanceingalls merged 2 commits intomainfrom
vance/shader-midpoint-tests
Apr 23, 2026
Merged

test(shader-transitions): add midpoint (p=0.5) regression invariants for all shaders#378
vanceingalls merged 2 commits intomainfrom
vance/shader-midpoint-tests

Conversation

@vanceingalls
Copy link
Copy Markdown
Collaborator

@vanceingalls vanceingalls commented Apr 21, 2026

Summary

Add four midpoint (p=0.5) regression invariants applied via a describe loop over ALL_SHADERS, so every existing and future shader transition automatically gets coverage at the most viewer-visible point in the animation.

Why

Chunk 9G of plans/hdr-followups.md. Existing smoke tests cover only the endpoints (p=0 ≈ from, p=1 ≈ to), which miss a class of regressions that surface specifically at the midpoint and let shaders silently rot in CI:

  • A shader becomes a no-op (returns input as-is)
  • A shader prematurely completes (returns target at midpoint)
  • A shader doesn't write to the output buffer at all
  • A shader loses determinism (Math.random / Date.now / leaked state)

What changed

packages/engine/src/utils/shaderTransitions.test.ts: a single describe loop over ALL_SHADERS that asserts at p=0.5:

  1. output ≠ from — catches no-ops
  2. output ≠ to — catches premature completion
  3. output is non-zero — catches blank output
  4. output is deterministic — catches accidental non-determinism

Uses two distinct uniform input colors (40000/30000/20000 vs 10000/10000/10000) so equality checks have distinct byte patterns to compare against. Even shaders that warp UVs (which would be no-ops on uniform input alone) produce mix16(from, to, 0.5) at every pixel, distinct from both inputs.

Test plan

  • 60 new tests (4 invariants × 15 shaders), all passing.
  • Any new transition added to the registry automatically picks up the same coverage.

Stack

Chunk 9G of plans/hdr-followups.md. Test-only change, independent of all other chunks.

Copy link
Copy Markdown
Collaborator Author

vanceingalls commented Apr 21, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from a1d1fdd to afe3517 Compare April 21, 2026 20:48
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch 2 times, most recently from 2163cd0 to ca9c359 Compare April 21, 2026 20:54
@vanceingalls vanceingalls marked this pull request as ready for review April 21, 2026 20:57
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from ca9c359 to d8c43e8 Compare April 21, 2026 22:37
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from 2af7fa2 to f675c92 Compare April 22, 2026 01:16
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from d8c43e8 to 1733e38 Compare April 22, 2026 01:16
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from f675c92 to b09ef42 Compare April 22, 2026 02:03
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from 1733e38 to 6881964 Compare April 22, 2026 02:03
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from 23721fc to 29fbdb2 Compare April 23, 2026 03:19
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from 1655176 to 16e2fa4 Compare April 23, 2026 03:19
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from 29fbdb2 to 73a1f75 Compare April 23, 2026 03:40
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from 16e2fa4 to 58f97e9 Compare April 23, 2026 03:41
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from 73a1f75 to 01eb2f9 Compare April 23, 2026 04:49
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from 58f97e9 to ea05258 Compare April 23, 2026 04:49
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from 01eb2f9 to 1ee49d8 Compare April 23, 2026 05:08
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from ea05258 to b4fa284 Compare April 23, 2026 05:09
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from 1ee49d8 to 981e6a8 Compare April 23, 2026 05:44
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch 2 times, most recently from 193ed00 to ff0f25b Compare April 23, 2026 06:07
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch 2 times, most recently from b66e6e5 to c694a91 Compare April 23, 2026 06:57
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from ff0f25b to e24208f Compare April 23, 2026 06:57
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from c694a91 to c642d12 Compare April 23, 2026 15:33
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from e24208f to 2f4a04b Compare April 23, 2026 15:33
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch 2 times, most recently from b91be60 to 699fd72 Compare April 23, 2026 16:32
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch 2 times, most recently from cd80985 to 9bba00a Compare April 23, 2026 16:35
@vanceingalls vanceingalls force-pushed the vance/srgb-hdr-reference-tests branch from 699fd72 to 2e76501 Compare April 23, 2026 16:35
@vanceingalls vanceingalls changed the base branch from vance/srgb-hdr-reference-tests to graphite-base/378 April 23, 2026 17:37
…d-transfer caller error

PR #370 review feedback (jrusso1020):

- chunkEncoder: when codec=h264 and hdr is set, log a warning and strip
  hdr instead of emitting a half-HDR file (BT.2020 container tags +
  BT.709 VUI inside the bitstream). libx264 has no HDR support; the only
  honest output is SDR/BT.709. Caller is told to use codec=h265.

- videoFrameExtractor: comment at the convertSdrToHdr call site clarifying
  that dominantTransfer is majority-wins; mixing PQ and HLG sources in a
  single composition is caller-error and the minority transfer's videos
  will be converted with the wrong curve. Render two compositions if you
  need both transfers.

- docs/guides/hdr.mdx: limitations section now documents (a) H.264 + HDR
  is rejected at the encoder layer, and (b) GPU H.265 (nvenc, videotoolbox,
  qsv, vaapi) emits BT.2020 + transfer tags but does NOT embed master-display
  or max-cll SEI, since ffmpeg won't pass x265-params through hardware
  encoders. Acceptable for previews, not for HDR10 delivery.
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from 9bba00a to 66d4398 Compare April 23, 2026 17:38
@graphite-app graphite-app Bot changed the base branch from graphite-base/378 to main April 23, 2026 17:38
…for all shaders

Existing smoke tests cover only the endpoints (p=0 ≈ from, p=1 ≈ to),
which miss a class of regressions that surface specifically at the
midpoint — where the transition is most visible to viewers — and let
shaders silently rot in CI:

  • A shader becomes a no-op (returns input as-is)
  • A shader prematurely completes (returns target at midpoint)
  • A shader doesn't write to the output buffer at all
  • A shader loses determinism (Math.random / Date.now / leaked state)

Add four invariants every shader must satisfy at p=0.5, applied via a
describe loop over ALL_SHADERS so any new transition added to the
registry automatically picks up the same coverage:

  1. output ≠ from           catches no-ops
  2. output ≠ to             catches premature completion
  3. output is non-zero      catches blank output
  4. output is deterministic catches accidental non-determinism

Uses two distinct uniform input colors (40000/30000/20000 vs
10000/10000/10000) so equality checks have distinct byte patterns to
compare against. Even shaders that warp UVs (which would be no-ops on
uniform input alone) produce mix16(from, to, 0.5) at every pixel,
distinct from both inputs.

60 new tests (4 invariants × 15 shaders), all passing.

Follow-up to plans/hdr-followups.md Chunk 9G.
@vanceingalls vanceingalls force-pushed the vance/shader-midpoint-tests branch from 66d4398 to 7b9eb89 Compare April 23, 2026 17:38
@vanceingalls vanceingalls merged commit 4101cb7 into main Apr 23, 2026
32 of 33 checks passed
Copy link
Copy Markdown
Collaborator Author

Merge activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants